package com.bifrost.entity;

import com.bifrost.constant.BonusPointsSource;
import com.bifrost.constant.BonusPointsUpdatedDetail;
import com.bifrost.constant.BonusPointsUpdatedType;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.math.BigInteger;
import java.util.Date;

/**
 * @author rangf
 * @date 2018/1/9
 */
@Entity
@Table(name = "BONUS_POINTS_HISTORY",indexes = {
        @Index(name = "NUMBE_TYPE_INDEX",columnList = "NUMBER,UPDATED_TYPE",unique = true)
})
@NamedQuery(name = "BonusPointsHistory.findAll", query = "SELECT p FROM BonusPointsHistory p")
public class BonusPointsHistory {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "BONUSPOINTS_HISTORY_ID", unique = true, nullable = false)
    private Long bonusPointsHistory;

    /**
     * 业务流水号
     * */
    @Column(name = "TRANSACTION_ID", unique = true, nullable = false)
    private Long transactionId;

    /**
     * 业务相关凭证号、包括但不限于订单号、券号
     */
    @Column(name = "NUMBER", length = 32,nullable = true)
    private String number;

    /**
     * 用户id
     */
    @Column(name = "CUSTOMER_ID")
    private Long customerId;

    /**
     * 原单号
     */
    @Column(name = "ORIGIN_NUMBER", length = 32)
    private String originNumber;


    /**
     * 会员卡号
     */
    @Column(name = "CARD_NUMBER", length = 32)
    private String cardNumber;

    /**
     * 会员名称
     */
    @Column(name = "CUSTOMER_LASTNAME", length = 32)
    private String customerLastName;

    /**
     * 会员电话
     */
    @Column(name = "CUSTOMER_PHONE", length =16)
    private String customerPhone;

    /**
     * 门店号
     */
    @Column(name = "MERCHANT_ID")
    private Long merchantId;

    /**
     * 门店编码
     */
    @Column(name = "STORE_CODE",length = 16)
    private String storeCode;

    /**
     * 修改后的值
     */
    @Column(name = "AFTER_VALUE")
    private BigInteger afterValue;

    /**
     * 变动值
     */
    @Column(name = "UPDATED_VALUE")
    private BigInteger updatedValue;

    /**
     * 来源
     */
    @Column(name = "SOURCE", length = 32)
    @Enumerated(value = EnumType.STRING)
    private BonusPointsSource source;
    /**
     * 备注
     */
    @Column(name = "REMARK")
    private String remark;

    @Column(name="CREATE_BY",length = 20)
    private String createBy;

    /**
     * 积分变动类型+INCREMENT、-DECREMENT
     */
    @Column(name = "UPDATED_TYPE", length = 32,nullable = false)
    @Enumerated(value = EnumType.STRING)
    private BonusPointsUpdatedType updatedType;

    @Column(name = "UPDATED_TYPE_DETAIL", length = 32,nullable = false)
    @Enumerated(value = EnumType.STRING)
    private BonusPointsUpdatedDetail updatedTypeDetail;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "UPDATED_TIMESTAMP")
    private Date updatedTimestamp;

   /* @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CUSTOMER_ID", nullable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
    private Customer customer;*/

    /**
     * 记录原始数据
     * */
    @Column(name = "DATA")
    @Lob
    @JsonIgnore
    private String data;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getBonusPointsHistory() {
        return bonusPointsHistory;
    }

    public void setBonusPointsHistory(Long bonusPointsHistory) {
        this.bonusPointsHistory = bonusPointsHistory;
    }

    public BigInteger getAfterValue() {
        return afterValue;
    }

    public void setAfterValue(BigInteger afterValue) {
        this.afterValue = afterValue;
    }

    public BigInteger getUpdatedValue() {
        return updatedValue;
    }

    public void setUpdatedValue(BigInteger updatedValue) {
        this.updatedValue = updatedValue;
    }

    public BonusPointsUpdatedType getUpdatedType() {
        return updatedType;
    }

    public void setUpdatedType(BonusPointsUpdatedType updatedType) {
        this.updatedType = updatedType;
    }

    public BonusPointsUpdatedDetail getUpdatedTypeDetail() {
        return updatedTypeDetail;
    }

    public void setUpdatedTypeDetail(BonusPointsUpdatedDetail updatedTypeDetail) {
        this.updatedTypeDetail = updatedTypeDetail;
    }

    public Date getUpdatedTimestamp() {
        return updatedTimestamp;
    }

    public void setUpdatedTimestamp(Date updatedTimestamp) {
        this.updatedTimestamp = updatedTimestamp;
    }

   /* public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }
*/
    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getOriginNumber() {
        return originNumber;
    }

    public void setOriginNumber(String originNumber) {
        this.originNumber = originNumber;
    }

    public String getCardNumber() {
        return cardNumber;
    }

    public void setCardNumber(String cardNumber) {
        this.cardNumber = cardNumber;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public String getStoreCode() {
        return storeCode;
    }

    public void setStoreCode(String storeCode) {
        this.storeCode = storeCode;
    }

    public BonusPointsSource getSource() {
        return source;
    }

    public void setSource(BonusPointsSource source) {
        this.source = source;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Long getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(Long transactionId) {
        this.transactionId = transactionId;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public String getCustomerLastName() {
        return customerLastName;
    }

    public void setCustomerLastName(String customerLastName) {
        this.customerLastName = customerLastName;
    }

    public String getCustomerPhone() {
        return customerPhone;
    }

    public void setCustomerPhone(String customerPhone) {
        this.customerPhone = customerPhone;
    }
}
